<?php
/*
 * Created on 05-05-2011
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
 require_once('Codes.php');
 require_once('DS.php');
 require_once('Entanglement.php');
 
 if(!empty($_POST)){
  	if(!isset($_POST['userId'])){
    	return constant("ARGUMENT_NULL").':userId';
  	}
  $userId = $_POST['userId'];
  
    if(!isset($_POST['timestamp'])){
    	return constant("ARGUMENT_NULL").':timestamp';
  	}
  $timestamp = $_POST['timestamp'];
  } else{
	return constant("ARGUMENT_NULL").':ALL';
  }

  $eId = Entanglement::GetEID($userId);
  Open();
	$timestamp = mysql_real_escape_string($timestamp);
	$r = Run("SELECT R_ID FROM tbl_requests WHERE E_ID = '$eId' AND MsgDate >= '$timestamp' ORDER BY R_ID ASC");
	if($r != false){
		$numRows = mysql_numrows($r);
		if($numRows>0){
			$ridList = array();
			for($i = 0; $i < $numRows; ++$i){
			  $ridList[$i] =  mysql_result($r,$i,"R_ID");
			}
			$ridStr = implode(',',$ridList);
			echo constant("HAS_MESSAGE").":$ridStr";
		}else{
			echo constant("NO_MESSAGES");
		}
	} else{
		echo constant("TECH_ERROR").':'.mysql_error();
	}
  Close();
?>
